I've got this script that will run recursive traceability in a single column (I've got 8.1). I can't figure out why it won't display any results until one of the links is physically followed. It looks to me like it's supposed to open modules in the background via the "read" function, however, it does not seem to.
figure'd I'd submit it to the experts.
Thanks
Rich
//////////////
Module m = current
Link l
int depth
int n=0
string linkModName
void getInfo (Object local_o, string srcIdent, string firstO, int local_depth) {
Array linkstore = create(10,3)
string trgIdent
if (local_o != null) {
// - get the heading and paragraph number
string shead = ""
string sParagraph = ""
shead = local_o."Object Heading"
sParagraph = number local_o
if (shead == "") {
// - get the heading for the parent object
oParent = parent(local_o)
if (oParent != null) {
shead = oParent."Object Heading"
sParagraph = number oParent
}
}
// Store the information
trgIdent = identifier local_o
string sDisp1 = name module local_o
string sDisp2 = sParagraph " " shead " " richTextWithOle(local_o."Object Text") " "
put(linkstore,sDisp1,0,0)
put(linkstore,sDisp2,0,1)
}
string xout1 = get(linkstore,0,0)
string xout2 = get(linkstore,0,1)
linkInfo = ""
if (local_depth <= 5) {
linkInfo = "\n" "\\b " linkModName "<-"
}
linkInfo = linkInfo "\\b " xout1 ": " xout2
//insertion of new command
linkInfo = applyTextFormattingToParagraph(linkInfo, false, (local_depth*500), 0)
displayRich linkInfo
delete (linkstore)
return
}
string isLink (Object local_o, string first_oIdent) {
tempString = ""
string sourceIdent = identifier local_o
bool lFound = false
if (sourceIdent != first_oIdent) {
depth ++
}
for l in local_o <- "*" do {
// make sure the module is open in at least read-only mode
string trgPath = fullName(source l)
if (exists(module trgPath) == true) {
if (open(module trgPath) == false) {
read(trgPath,false)
}
}
lFound = true
Object trgObj = source l
linkModName = name module l
string trg_Ident = identifier trgObj
getInfo (trgObj, sourceIdent, first_oIdent, depth)
tempString = isLink (trgObj, first_oIdent)
if (tempString == "No Link") {
depth --
display ""
}
}
string rtnString = "No Link"
return rtnString
}
string oIdent = identifier obj
depth = 0
isLink (obj, oIdent)
//////////////
richmason - Wed Feb 18 16:22:53 EST 2009 |
|
Re: Recursive Traceability Tony_Goodman - Thu Feb 19 04:31:03 EST 2009
You need to use LinkRef type to traverse incoming links and open modules. The Link type will not return anything until the source module is open. Here is an example created by the wizard.
Notice that you use LinkRef first, opening modules where necessary. Then you do the loop using Link.
// DXL generated by DOORS traceability wizard on 06 January 2009.
// Wizard version 2.0, DOORS version 8.1.0.6
pragma runLim, 0
string limitModules[1] = {"45dab876463b3bbf-0000c260"}
void showIn(Object o, int depth) {
Link l
LinkRef lr
ModName_ otherMod = null
Module linkMod = null
ModuleVersion otherVersion = null
Object othero
string disp = null
string s = null
string plain, plainDisp
int plainTextLen
int count
bool doneOne = false
Item linkModItem = itemFromID("45dab876463b3bbf-0000c261")
if (null linkModItem) {
display("<<Link module not found>>")
} else if (type(linkModItem) != "Link") {
display("<<Invalid link module index for this database>>")
} else {
string linkModName = fullName(linkModItem)
for lr in all(o<-linkModName) do {
otherMod = module (sourceVersion lr)
if (!null otherMod) {
if ((!isDeleted otherMod) && (null data(sourceVersion lr))) {
if (!equal(getItem otherMod, (itemFromID limitModulesdepth-1))) continue
load((sourceVersion lr),false)
}
}
}
for l in all(o<-linkModName) do {
otherVersion = sourceVersion l
otherMod = module(otherVersion)
if (null otherMod || isDeleted otherMod) continue
if (!equal(getItem otherMod, (itemFromID limitModulesdepth-1))) continue
othero = source l
if (null othero) {
load(otherVersion,false)
}
othero = source l
if (null othero) continue
if (isDeleted othero) continue
doneOne = true
if (depth == 1) {
disp = ""
s = probeRichAttr_(othero,"Test ID", false)
disp = disp s
s = probeRichAttr_(othero,"Object Heading", false)
disp = disp " " s
displayRich disp
}
}
}
}
showIn(obj,1)
|
|
Re: Recursive Traceability richmason - Thu Feb 19 15:46:16 EST 2009 Tony_Goodman - Thu Feb 19 04:31:03 EST 2009
You need to use LinkRef type to traverse incoming links and open modules. The Link type will not return anything until the source module is open. Here is an example created by the wizard.
Notice that you use LinkRef first, opening modules where necessary. Then you do the loop using Link.
// DXL generated by DOORS traceability wizard on 06 January 2009.
// Wizard version 2.0, DOORS version 8.1.0.6
pragma runLim, 0
string limitModules[1] = {"45dab876463b3bbf-0000c260"}
void showIn(Object o, int depth) {
Link l
LinkRef lr
ModName_ otherMod = null
Module linkMod = null
ModuleVersion otherVersion = null
Object othero
string disp = null
string s = null
string plain, plainDisp
int plainTextLen
int count
bool doneOne = false
Item linkModItem = itemFromID("45dab876463b3bbf-0000c261")
if (null linkModItem) {
display("<<Link module not found>>")
} else if (type(linkModItem) != "Link") {
display("<<Invalid link module index for this database>>")
} else {
string linkModName = fullName(linkModItem)
for lr in all(o<-linkModName) do {
otherMod = module (sourceVersion lr)
if (!null otherMod) {
if ((!isDeleted otherMod) && (null data(sourceVersion lr))) {
if (!equal(getItem otherMod, (itemFromID limitModulesdepth-1))) continue
load((sourceVersion lr),false)
}
}
}
for l in all(o<-linkModName) do {
otherVersion = sourceVersion l
otherMod = module(otherVersion)
if (null otherMod || isDeleted otherMod) continue
if (!equal(getItem otherMod, (itemFromID limitModulesdepth-1))) continue
othero = source l
if (null othero) {
load(otherVersion,false)
}
othero = source l
if (null othero) continue
if (isDeleted othero) continue
doneOne = true
if (depth == 1) {
disp = ""
s = probeRichAttr_(othero,"Test ID", false)
disp = disp s
s = probeRichAttr_(othero,"Object Heading", false)
disp = disp " " s
displayRich disp
}
}
}
}
showIn(obj,1)
unfortunately, I'm not a good enough coder to modify the code. Been messing with it today and haven't gotten it to work. I understand the principle, I just can't code it.
|
|
Re: Recursive Traceability Tony_Goodman - Fri Feb 20 09:45:52 EST 2009 richmason - Thu Feb 19 15:46:16 EST 2009
unfortunately, I'm not a good enough coder to modify the code. Been messing with it today and haven't gotten it to work. I understand the principle, I just can't code it.
It is not clear from your code exactly what is is that you are trying to do.
Can you explain what you want to see in the column and we'll have a stab at that.
|
|
Re: Recursive Traceability richmason - Fri Feb 20 10:13:37 EST 2009 Tony_Goodman - Fri Feb 20 09:45:52 EST 2009
It is not clear from your code exactly what is is that you are trying to do.
Can you explain what you want to see in the column and we'll have a stab at that.
Hi Tony
the script shows recursive traceability in one column via indentions at different levels of recursion. The hang up with the script I have is that the modules must physically be opened. The other replier suggested a tweak to the code, but I was unable to implement because I am not a strong coder. The tweak being that the script would not require the modules to be opened first to display a result in its column.
I would like the script to display the recursive traceability of ANY inlink (I think this is the inlink one, I have another for outlinks) without the modules actually having to be manually opened.
Rich
|
|
Re: Recursive Traceability SystemAdmin - Mon Feb 23 01:48:56 EST 2009 richmason - Fri Feb 20 10:13:37 EST 2009
Hi Tony
the script shows recursive traceability in one column via indentions at different levels of recursion. The hang up with the script I have is that the modules must physically be opened. The other replier suggested a tweak to the code, but I was unable to implement because I am not a strong coder. The tweak being that the script would not require the modules to be opened first to display a result in its column.
I would like the script to display the recursive traceability of ANY inlink (I think this is the inlink one, I have another for outlinks) without the modules actually having to be manually opened.
Rich
If I was to have a guess at what I think the problem is here, I think it's to do with the Analysis Wizard when defining a traceability column. This sounds like the option "All Open Modules" has been selected instead of just "All Modules". I would suggest using the Analysis Wizard to create a new traceability column but make sure that the "All Modules" radio button is selected when you're on step 2 of the wizard "Scope of Analysis".
Paul Miller
EuroCyber
Melbourne, Australia
|
|
Re: Recursive Traceability richmason - Mon Feb 23 08:37:07 EST 2009 SystemAdmin - Mon Feb 23 01:48:56 EST 2009
If I was to have a guess at what I think the problem is here, I think it's to do with the Analysis Wizard when defining a traceability column. This sounds like the option "All Open Modules" has been selected instead of just "All Modules". I would suggest using the Analysis Wizard to create a new traceability column but make sure that the "All Modules" radio button is selected when you're on step 2 of the wizard "Scope of Analysis".
Paul Miller
EuroCyber
Melbourne, Australia
Hi Paul
The script I posted in the intial thread was not created using the Analysis Wizard, and that is what I was asking about. It seems like maybe you are referring to the script posted after that, that WAS created using the Analysis Wizard.
The script I posted will include all the traceability in one column, whereas the Analysis Wizard for 8.1 will only include one level of recursion on one column. We have not migrated to 9.1 yet, and I hear that 9.1 does have that capability.
Best,
Rich
|
|
Re: Recursive Traceability SystemAdmin - Mon Feb 23 15:30:13 EST 2009 richmason - Mon Feb 23 08:37:07 EST 2009
Hi Paul
The script I posted in the intial thread was not created using the Analysis Wizard, and that is what I was asking about. It seems like maybe you are referring to the script posted after that, that WAS created using the Analysis Wizard.
The script I posted will include all the traceability in one column, whereas the Analysis Wizard for 8.1 will only include one level of recursion on one column. We have not migrated to 9.1 yet, and I hear that 9.1 does have that capability.
Best,
Rich
Hi Rich,
The DXL code used for the single column recursive trace feature in DOORS 9v0 and later seems to use standard library functions and I've managed to port it to 7v1 and 8v3 and it works fine on those versions, so it should work on 8v1 as well. I've attached a copy of the code as generatd by the 9v0 Analysis Wizard, this might help as a reference.
Paul Miller
EuroCyber
Melbourne, Australia
Attachments
attachment_14220468_SingleColumnRecursiveTrace.dxl
|
|